<div class="loading-container"><div class="loader"></div></div>

<div class="wrapper wrapper-shadow wrapper-list">
	<!-- list data wrapper -->
	<div class="result-wrapper">
   	<div class="content-wrapper no-padding">
     	<div class="content-body">
     		<div class="tabs">
           <ul class="nav nav-tabs widget">
             <li class="active"> 
             	<a href="#tab-content" data-toggle="tab" onclick="handlerToggle('F')" data-table-target="#table-room" data-form-search="#search-form-room"> 
             		<span class="menu-icon"><i class="fa fa-user-plus"></i></span> 教室信息
             	</a>
             </li>
             <li > 
             	<a href="#tab-content" data-toggle="tab" onclick="handlerToggle('T')" data-table-target="#table-room" data-form-search="#search-form-room"> 
             		<span class="menu-icon"><i class="fa fa-stop-circle-o"></i></span> 已删除教室
             	</a>
             </li>
           </ul>
           <div class="tab-content no-border xs-padding">
             <div class="tab-pane active" id="tab-content">
             	<div id="toolbar" class="btn-group">
						    <button type="button" class="btn btn-primary" onclick="handlerCreate(this);" data-editor-path="/miwawa/content/eam/room/editor/" data-editor-page="add.html">
				        	<i class="glyphicon glyphicon-plus"></i> 新增
						    </button>
							</div>
             	<table data-ajax="handlerSearch" 
           					 data-method="post" 
										 data-search="true" 
										 data-toolbar="#toolbar" 
            				 data-id-field="id" 
            				 data-unique-id="id" 
										 data-pagination="true" 
										 data-show-toggle="true" 
										 data-show-refresh="true" 
										 data-show-columns="true" 
										 data-check-on-init="true" 
										 data-click-to-select="false" 
										 data-side-pagination="server" 
										 data-mobile-responsive="true" 
										 data-event-onload="handlerSuccess" 
									 	 data-form-search="#search-form-room" id="table-room" class="bootstrap-table">
								<thead>
									<tr>
										<th data-checkbox="true"></th>
										<th data-field="id" data-visible="false" data-switchable="false">ID</th>
										<th data-field="type" 		data-align="center" >教室类型</th>
										<th data-field="name" 		data-align="center" >教室名称</th>
										<th data-field="code" 		data-align="center" >房间号</th>
										<th data-field="area" 		data-align="center" >面积</th>
										<th data-field="contain" 	data-align="center" >容纳人数</th>
										<th data-field="operator" data-align="center" data-width="65" data-formatter="renderOperator" data-table-target="room">操作</th>
									</tr>
								</thead>
							</table>
             </div>
           </div>
         </div>
     	</div>
   	</div>
	</div>

	<!-- form editor wrapper -->
	<div class="editor-wrapper">
		
	</div>
</div>
<!-- PAGE CONTENT END =============================================== -->

<!-- 查询表单 ========================================================= -->
<form id="search-form-room" action="/miwawa/{dbname}/common/search.json" method="post" 
			name="com.app.miwawa.api.eam.entity.Room">
			<input type="hidden" name="status" value="0" data-search-group="and" data-search-operation="EQ">
			<input type="hidden" name="invalid" value="F" data-search-group="and" data-search-operation="EQ">
</form>
<!-- 删除表单 ========================================================= -->
<form id="remove-form-room" action="/miwawa/{dbname}/classes/room/delete" method="post"></form>

<!-- Javascript ===================================================== -->
<script src="/miwawa/resources/lib/miwawa/1.0.2/js/core/requirejs/require.js"></script>
<script type="text/javascript">
<!--
	jQuery(function(){
		require(['/miwawa/resources/lib/miwawa/1.0.2/js/core/module/app/simple.js'], function(simple){
			simple(['registerForm','registerTable','registerWidget']);
		});
	});
	
	function renderOperator(value, row, index){
		switch(row.invalid){
		case "F":
			return "<a class='btn btn-info 	 btn-xs btn-table-op'  onclick='handlerCreate(this, \""+row.id+"\")' data-table-source='#table-room' data-editor-path='/miwawa/content/eam/room/editor/' data-editor-page='edit.html' data-toggle='tooltip' data-placement='top' title='查看与编辑'> <i class='ion-compose'></i> </a>"
					 + "<a class='btn btn-danger btn-xs btn-table-op'  onclick='operateRoom(this, \""+row.id+"\", \"delete\")' data-toggle='tooltip' data-placement='top' title='删除' > <i class='fa fa-trash'></i> </a>";  
		case "T":	
			return "<a class='btn btn-success btn-xs btn-table-op' onclick='operateRoom(this, \""+row.id+"\", \"reback\")' data-toggle='tooltip' data-placement='top' title='恢复' > <i class='fa fa-reply'></i> </a>";  
		}	
	}
	
	function handlerToggle(value){		
		// 设置查询参数
		if(value == "T"){
			jQuery(":hidden[name='invalid']","#search-form-room").val("T");
			jQuery(".btn-group-add").hide(); 
		}else{
			jQuery(":hidden[name='invalid']","#search-form-room").val("F");
			jQuery(".btn-group-add").show();
		}
		jQuery("#table-room").bootstrapTable('refreshOptions',{"searchText":null});
		jQuery("#table-room").bootstrapTable('refresh');
	}
	
	//删除和还原教室
	function operateRoom(button, roomid, operation){
		if(operation == "delete"){
			jQuery.message.confirm("确定要删除该教室吗？删除的教室可在已删除教室中恢复。",function(confirm){
				if(confirm){
					jQuery.ajaxsend({
						url:(("/miwawa/{dbname}/classes/room/{operation}/{roomid}".replace("{dbname}",dbname)).replace("{operation}",operation)).replace("{roomid}",roomid),
					  success:function(){
						  jQuery.message.success("所选教室已删除");
							jQuery(button).tooltip("destroy");
							jQuery("#table-room").bootstrapTable("refresh");
					  }			
					});
				}
			});
		}else{
			jQuery.ajaxsend({
				url:(("/miwawa/{dbname}/classes/room/{operation}/{roomid}".replace("{dbname}",dbname)).replace("{operation}",operation)).replace("{roomid}",roomid),
			  success:function(){
				  jQuery.message.success("所选教室已还原");
					jQuery(button).tooltip("destroy");
					jQuery("#table-room").bootstrapTable("refresh");
			  }			
			});
		}
	}
//-->
</script>